module executor.friend.client.DeleteFriendExecutor;

import msgtrans;
import message.Constants;
import message.MsgDefine;
import google.protobuf;
import hunt.logging;
import client.ImClient;
import std.array;
import std.conv : to;

@TransportClient(msgClientName)
class DeleteFriendExecutor : AbstractExecutor!(DeleteFriendExecutor) {

    @MessageId(MESSAGE.CMD_DELETE_FRIEND_RES)
    void deleteFriend(TransportContext ctx, MessageBuffer buffer)
    {
      auto res = new DeleteContactRES();
      buffer.data.fromProtobuf!DeleteContactRES( res);
      TransportSession[] clients =  ImClient.getInstance().getImClient( to!ulong( res.userId));
      foreach (TransportSession client ; clients)
      {
        client.send( new MessageBuffer( MESSAGE.CMD_DELETE_FRIEND_RES,res.toProtobuf.array));
      }
      //if (c !is null)
      //{
      //  c.send( new MessageBuffer( MESSAGE.CMD_DELETE_FRIEND_RES,res.toProtobuf.array));
      //}else
      //{
      //  logWarning( "deleteFriend user %d is offline",res.userId);
      //}
    }
}

